/****************************************************************************

****************************************************************************/

#include "application.hpp"
#include "iostream"

static void cancel()
{
    Application * const app = Application::instance();
    if (app)
        app->userInterrupt();
}
#if defined(Q_OS_WIN) /*&& defined(Q_CC_MSVC)*/

#include <qt_windows.h>

static BOOL WINAPI consoleCtrlHandlerRoutine( DWORD dwCtrlType )
{
    Q_UNUSED(dwCtrlType);
    cancel();
    return TRUE;
}
void installCtrlCHandler()
{
    SetConsoleCtrlHandler(&consoleCtrlHandlerRoutine, TRUE);
}
#else

#include <csignal>

static void sigIntHandler(int sig)
{
    Q_UNUSED(sig);
    cancel();
}
void installCtrlCHandler()
{
    signal(SIGINT, sigIntHandler);
}
#endif
